package cn.com.ebidding.spc.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created on 2020/10/21.
 *
 * @author qiyang.
 * 描述：演示获取配置中心配置
 */
@RestController
@RefreshScope
@RequestMapping(value = "/consumer")
public class ConfigClientController {

    @Value("${server.port}")
    private String port;

    @Value("${config.file.info}")
    private String configInfo;

    @Value("${config.bs.info}")
    private String configBsInfo;

    @Value("${registry.eureka.serviceUrl}")
    private String serviceUrl;

    @Value("${eureka.client.service-url.defaultZone}")
    private String defaultZone;

    @GetMapping("config/info")
    public String getConfig(){

        return "获取到的配置为 -> " + configInfo + "来自服务端口为：" + port;
    }

    @GetMapping("config/info/bs")
    public String getConfigBs(){

        return "获取到的配置为 -> " + configBsInfo;
    }

    @GetMapping("config/info/serviceUrl")
    public String getServiceUrl(){

        return "获取到的配置为 -> " + serviceUrl;
    }

    @GetMapping("config/info/defaultZone")
    public String getDefaultZone(){

        return "获取到的配置为 -> " + defaultZone;
    }

}
